package com.jgj.zxkj.lookandcheckjggroupinfo.record.nocheck;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.jgj.zxkj.lookandcheckjggroupinfo.R;
import com.jgj.zxkj.lookandcheckjggroupinfo.constants.Constants;
import com.sa.all_cui.mix_core.delegate.DoggerDelegate;
import com.sa.all_cui.mix_ui.recycler.BaseDecoration;
import com.sa.all_cui.mix_ui.recycler.CustomLayoutManager;

import butterknife.BindView;

/**
 * Created by all-cui on 2017/10/27.
 */

public class NoCheckDelegate extends DoggerDelegate {
    @BindView(R.id.srl_common_check)
    SwipeRefreshLayout mRefreshLayout = null;
    @BindView(R.id.rv_common_check)
    RecyclerView mRv = null;
    private RefreshLoadMoreHandler mRefreshHandler = null;

    @Override
    public Object setLayout() {
        return R.layout.delegate_common_check;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View view) {
        mRefreshHandler = RefreshLoadMoreHandler.create(mRefreshLayout, mRv, new NoCheckDataConvert());
    }

    private void initRefreshLayout() {
        mRefreshLayout.setColorSchemeResources(
                android.R.color.holo_red_dark,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light
        );
        //设置加载圆圈起始位置和结束位置，并且开始是由小变大，结束是由小变大
        mRefreshLayout.setProgressViewOffset(true, 120, 300);
    }

    private void initRecycleView() {
        CustomLayoutManager layoutManager = new CustomLayoutManager(mRv.getContext());
        mRv.setLayoutManager(layoutManager);
        //设置分割线
        mRv.addItemDecoration(BaseDecoration.
                create(ContextCompat.getColor(getContext(),
                        R.color.app_divider_gray), 5));
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        initRefreshLayout();
        initRecycleView();
        NoCheckDelegate delegate = this;
        mRefreshHandler.setPageUrl("dlsh/queryPage")
                .setStatus(Constants.STATUS_NO_CHECK)
                .setDelegate(delegate)
                .retainPageFirstNet();

    }


}
